<template>
	<view class="topbar" :style="{'height':statusheight,'padding-top':topbarheight,'background-color':settings.backgroundColor}">
		{{settings.title}}
	</view>
</template>

<script>
	export default {
		name:"topbar",
		// 传参
		props:[
			'settings'
		],
		data() {
			return {
				statusheight:'',
				screenWidth:'',
				screenHeight:'',
				topbarheight:'',
			};
		},
		created(){
			this.getInfo();
			this.getheight()
			this.getscreenWidth()
			this.getscreenHeight()
			// console.log(123)
		},
		methods:{
			// 获取手机信息
			getInfo(){
				uni.getSystemInfo({success:(res)=>{
					console.log(res);
					this.statusheight = res.statusBarHeight + 'px';
					this.screenWidth = res.screenWidth+'px'
					this.screenHeight = res.screenHeight+'px'
					if(res.model.indexOf('iPhone')!==-1){
						this.topbarheight = 44+'px';
					}else{
						this.topbarheight = 48+'px'
					}
				}})
			},
			// 获取高度
			getheight(){
				this.$store.dispatch('getstatusheight',this.statusheight)
			},
			// 获取宽度
			getscreenWidth(){
				this.$store.dispatch("getscreenWidth",this.screenWidth)
			},
			// 获取手机高度
			getscreenHeight(){
				this.$store.dispatch("getscreenHeight",this.screenHeight)
			}
		},
	}
</script>

<style lang="scss">
	.topbar{
		position: fixed;
		z-index: 999;
		width: 100%;
		top: 0;
	}
</style>
